From b3fc0abc2386dfea6791b67e85fb93db322265cc Mon Sep 17 00:00:00 2001 From: tsteven4 Date: Thu, 28 Jun 2018 08:04:06 -0600 Subject: [PATCH] clang tidy uses const_cast. This was from the google-readability-casting check, but only Message: C-style casts are discouraged; use const_cast were accepted. --- an1sym.h | 2 +- arcdist.cc | 4 ++-- cet.cc | 12 ++++++------ cet_util.cc | 20 ++++++++++---------- compegps.cc | 4 ++-- cst.cc | 2 +- csv_util.cc | 6 +++--- discard.cc | 4 ++-- garmin_txt.cc | 16 ++++++++-------- gdb.cc | 2 +- height.cc | 2 +- humminbird.cc | 6 +++--- lowranceusr4.cc | 2 +- mmo.cc | 6 +++--- osm.cc | 6 +++--- position.cc | 4 ++-- raymarine.cc | 6 +++--- reverse_route.cc | 2 +- route.cc | 2 +- stmsdf.cc | 8 ++++---- swapdata.cc | 2 +- trackfilter.cc | 16 ++++++++-------- unicsv.cc | 2 +- util.cc | 14 +++++++------- vecs.cc | 6 +++--- 25 files changed, 78 insertions(+), 78 deletions(-) diff --git a/an1sym.h b/an1sym.h index 2e33d3094..ee0e02e4e 100644 --- a/an1sym.h +++ b/an1sym.h @@ -725,7 +725,7 @@ static int FindIconByGuid(GUID* guid, char** name) unsigned int i = 0; for (i = 0; i < (sizeof(default_guids)/sizeof(struct defguid)); i++) { if (!memcmp(guid, &default_guids[i].guid, sizeof(GUID))) { - *name = (char*) default_guids[i].name; + *name = const_cast(default_guids[i].name); return 1; } } diff --git a/arcdist.cc b/arcdist.cc index 1b95c0688..679a02b5e 100644 --- a/arcdist.cc +++ b/arcdist.cc @@ -87,14 +87,14 @@ void ArcDistanceFilter::arcdist_arc_disp_wpt_cb(const Waypoint* arcpt2) ed->prjlongitude = prjlon; ed->frac = frac; ed->arcpt1 = arcpt1; - ed->arcpt2 = (Waypoint*) arcpt2; + ed->arcpt2 = const_cast(arcpt2); } } waypointp->extra_data = ed; } } } - arcpt1 = (Waypoint*) arcpt2; + arcpt1 = const_cast(arcpt2); } void ArcDistanceFilter::arcdist_arc_disp_hdr_cb(const route_head*) diff --git a/cet.cc b/cet.cc index bd14b8fad..ecb036d13 100644 --- a/cet.cc +++ b/cet.cc @@ -163,7 +163,7 @@ cet_utf8_to_ucs4(const char* str, int* bytes, int* value) if ((*cp & 0xc0) != 0x80) { break; /* invalid */ } else if (i == 0) { /* all valid */ - char* c = (char*)str; /* found valid sequence, now storing value */ + char* c = const_cast(str); /* found valid sequence, now storing value */ int res = *c++ & (mask ^ 0xFF); i = len; while (i-- > 0) { @@ -205,7 +205,7 @@ cet_ucs4_to_char(const int value, const cet_cs_vec_t* vec) { cet_ucs4_link_t* link; - if ((link = (cet_ucs4_link_t*)vec->ucs4_link)) { + if ((link = const_cast(vec->ucs4_link))) { int i = 0; int j = vec->ucs4_links - 1; /* validate ucs value against vec */ while (i <= j) { @@ -222,7 +222,7 @@ cet_ucs4_to_char(const int value, const cet_cs_vec_t* vec) } } - if ((link = (cet_ucs4_link_t*)vec->ucs4_extra)) { /* can be NULL */ + if ((link = const_cast(vec->ucs4_extra))) { /* can be NULL */ int i = 0; int j = vec->ucs4_extras - 1; while (i <= j) { @@ -362,7 +362,7 @@ cet_utf8_strndup(const char* str, const int maxlen) char* cet_str_utf8_to_any(const char* src, const cet_cs_vec_t* vec) { - char* c = (char*)src; + char* c = const_cast(src); int len; char* res, *dest, *cend; @@ -400,7 +400,7 @@ cet_str_any_to_utf8(const char* src, const cet_cs_vec_t* vec) char* result, *cin, *cout; char temp = CET_NOT_CONVERTABLE_DEFAULT; - cin = (char*)src; + cin = const_cast(src); if (cin == nullptr) { return nullptr; } @@ -417,7 +417,7 @@ cet_str_any_to_utf8(const char* src, const cet_cs_vec_t* vec) } result = cout = (char*) xmalloc(len + 1); - cin = (char*)src; + cin = const_cast(src); while (*cin != '\0') { if (CET_ERROR == cet_char_to_ucs4(*cin++, vec, &value)) { diff --git a/cet_util.cc b/cet_util.cc index 122b3f17c..e915170f6 100644 --- a/cet_util.cc +++ b/cet_util.cc @@ -155,7 +155,7 @@ cet_register() for (p = cet_cs_vec_root; p != nullptr; p = p->next) { c++; if (p->alias != nullptr) { - char** a = (char**)p->alias; + char** a = const_cast(p->alias); while ((*a) != nullptr) { a++; c++; @@ -168,7 +168,7 @@ cet_register() i = 0; for (p = cet_cs_vec_root; p != nullptr; p = p->next) { if (p->alias != nullptr) { - char** a = (char**)p->alias; + char** a = const_cast(p->alias); list[i].name = xstrdup(p->name); list[i].vec = p; @@ -322,13 +322,13 @@ cet_convert_init(const QString& cs_name, const int force) static void cet_flag_waypt(const Waypoint* wpt) { - ((Waypoint*)(wpt))->wpt_flags.cet_converted = 1; + (const_cast(wpt))->wpt_flags.cet_converted = 1; } static void cet_flag_route(const route_head* rte) { - ((route_head*)(rte))->cet_converted = 1; + (const_cast(rte))->cet_converted = 1; } static void @@ -391,7 +391,7 @@ cet_convert_string(const QString& str) static void cet_convert_waypt(const Waypoint* wpt) { - Waypoint* w = (Waypoint*)wpt; + Waypoint* w = const_cast(wpt); format_specific_data* fs; if ((cet_output == 0) && (w->wpt_flags.cet_converted != 0)) { @@ -414,7 +414,7 @@ cet_convert_waypt(const Waypoint* wpt) static void cet_convert_route_hdr(const route_head* route) { - route_head* rte = (route_head*)route; + route_head* rte = const_cast(route); if ((cet_output == 0) && (rte->cet_converted != 0)) { return; @@ -454,8 +454,8 @@ cet_convert_strings(const cet_cs_vec_t* source, const cet_cs_vec_t* target, cons cet_output = 1; converter = cet_convert_from_utf8; - cs_name_from = (char*)cet_cs_vec_utf8.name; - cs_name_to = (char*)target->name; + cs_name_from = const_cast(cet_cs_vec_utf8.name); + cs_name_to = const_cast(target->name); } else { if ((target != nullptr) && (target != &cet_cs_vec_utf8)) { fatal(MYNAME ": Internal error!\n"); @@ -464,8 +464,8 @@ cet_convert_strings(const cet_cs_vec_t* source, const cet_cs_vec_t* target, cons cet_output = 0; converter = cet_convert_to_utf8; - cs_name_to = (char*)cet_cs_vec_utf8.name; - cs_name_from = (char*)source->name; + cs_name_to = const_cast(cet_cs_vec_utf8.name); + cs_name_from = const_cast(source->name); } if (global_opts.debug_level > 0) { diff --git a/compegps.cc b/compegps.cc index b9a098016..74be6fa81 100644 --- a/compegps.cc +++ b/compegps.cc @@ -514,7 +514,7 @@ write_waypt_cb(const Waypoint* wpt) static void write_route_hdr_cb(const route_head* rte) { - curr_route = (route_head*) rte; + curr_route = const_cast(rte); curr_index++; if (curr_index != target_index) { return; @@ -540,7 +540,7 @@ static void write_track_hdr_cb(const route_head* trk) { track_info_flag = 0; - curr_track = (route_head*) trk; + curr_track = const_cast(trk); curr_index++; if (curr_index != target_index) { diff --git a/cst.cc b/cst.cc index 8a55f9f17..27f1fb735 100644 --- a/cst.cc +++ b/cst.cc @@ -69,7 +69,7 @@ cst_add_wpt(const route_head* track, Waypoint* wpt) } route_add_wpt(temp_route, new Waypoint(*wpt)); } - track_add_wpt((route_head*)track, wpt); + track_add_wpt(const_cast(track), wpt); } static char* diff --git a/csv_util.cc b/csv_util.cc index 36972bf7c..439f6f191 100644 --- a/csv_util.cc +++ b/csv_util.cc @@ -489,7 +489,7 @@ human_to_dec(const char* instr, double* outlat, double* outlon, int which) *c = '.'; } } else { - buff = (char*)instr; + buff = const_cast(instr); } cur = buff; @@ -1566,10 +1566,10 @@ xcsv_resetpathlen(const route_head* head) csv_route = csv_track = nullptr; switch (xcsv_file.datatype) { case trkdata: - csv_track = (route_head*) head; + csv_track = const_cast(head); break; case rtedata: - csv_route = (route_head*) head; + csv_route = const_cast(head); break; default: break; diff --git a/discard.cc b/discard.cc index e5b5de10a..18fa36214 100644 --- a/discard.cc +++ b/discard.cc @@ -39,7 +39,7 @@ void DiscardFilter::fix_process_wpt(const Waypoint* wpt) int delh = 0; int delv = 0; - Waypoint* waypointp = (Waypoint*) wpt; + Waypoint* waypointp = const_cast(wpt); if ((hdopf >= 0.0) && (waypointp->hdop > hdopf)) { delh = 1; @@ -107,7 +107,7 @@ void DiscardFilter::fix_process_wpt(const Waypoint* wpt) void DiscardFilter::fix_process_head(const route_head* trk) { - head = (route_head*)trk; + head = const_cast(trk); } void DiscardFilter::process() diff --git a/garmin_txt.cc b/garmin_txt.cc index 1f0b7805a..fcb6cda8e 100644 --- a/garmin_txt.cc +++ b/garmin_txt.cc @@ -212,13 +212,13 @@ enum_waypt_cb(const Waypoint* wpt) for (i = 0; i < wpt_a_ct; i++) { /* check for duplicates */ Waypoint* tmp = wpt_a[i]; if (case_ignore_strcmp(tmp->shortname, wpt->shortname) == 0) { - wpt_a[i] = (Waypoint*)wpt; + wpt_a[i] = const_cast(wpt); waypoints--; return; } } - wpt_a[wpt_a_ct++] = (Waypoint*)wpt; + wpt_a[wpt_a_ct++] = const_cast(wpt); } } @@ -259,10 +259,10 @@ prework_wpt_cb(const Waypoint* wpt) cur_info->time += (wpt->GetCreationTime().toTime_t() - prev->GetCreationTime().toTime_t()); cur_info->length += waypt_distance_ex(prev, wpt); } else { - cur_info->first_wpt = (Waypoint*)wpt; + cur_info->first_wpt = const_cast(wpt); cur_info->start = wpt->GetCreationTime().toTime_t(); } - cur_info->prev_wpt = (Waypoint*)wpt; + cur_info->prev_wpt = const_cast(wpt); cur_info->count++; routepoints++; } @@ -628,7 +628,7 @@ write_waypt(const Waypoint* wpt) static void route_disp_hdr_cb(const route_head* rte) { - current_trk = (route_head*)rte; + current_trk = const_cast(rte); cur_info = &route_info[route_idx]; cur_info->prev_wpt = nullptr; cur_info->total = 0; @@ -674,7 +674,7 @@ route_disp_wpt_cb(const Waypoint* wpt) gbfprintf(fout, "\r\n"); - cur_info->prev_wpt = (Waypoint*)wpt; + cur_info->prev_wpt = const_cast(wpt); } static void @@ -683,7 +683,7 @@ track_disp_hdr_cb(const route_head* track) cur_info = &route_info[route_idx]; cur_info->prev_wpt = nullptr; cur_info->total = 0; - current_trk = (route_head*)track; + current_trk = const_cast(track); if (track->rte_waypt_ct <= 0) { return; } @@ -745,7 +745,7 @@ track_disp_wpt_cb(const Waypoint* wpt) } gbfprintf(fout, "\r\n"); - cur_info->prev_wpt = (Waypoint*)wpt; + cur_info->prev_wpt = const_cast(wpt); } /******************************************************************************* diff --git a/gdb.cc b/gdb.cc index d9aebea23..e1a2f99c8 100644 --- a/gdb.cc +++ b/gdb.cc @@ -1629,7 +1629,7 @@ write_waypoint_cb(const Waypoint* refpt) /* do this when backup always happens in main */ #if NEW_STRINGS // but, but, casting away the const here is wrong... - ((Waypoint*)refpt)->shortname = refpt->shortname.trimmed(); + (const_cast(refpt))->shortname = refpt->shortname.trimmed(); #else rtrim(((Waypoint*)refpt)->shortname); #endif diff --git a/height.cc b/height.cc index 4f3b87c19..e691a5612 100644 --- a/height.cc +++ b/height.cc @@ -87,7 +87,7 @@ double HeightFilter::wgs84_separation(double lat, double lon) void HeightFilter::correct_height(const Waypoint* wpt) { - Waypoint* waypointp = (Waypoint*) wpt; + Waypoint* waypointp = const_cast(wpt); if (waypointp->altitude != unknown_alt) { if (addopt) { diff --git a/humminbird.cc b/humminbird.cc index d58d1ffb8..c65afb90c 100644 --- a/humminbird.cc +++ b/humminbird.cc @@ -953,13 +953,13 @@ humminbird_write_waypoint_wrapper(const Waypoint* wpt) xasprintf(&key, "%s\01%.9f\01%.9f", CSTRc(wpt->shortname), wpt->latitude, wpt->longitude); if (!(tmpwpt = map[key])) { - tmpwpt = (Waypoint*)wpt; - map[key] = (Waypoint*) wpt; + tmpwpt = const_cast(wpt); + map[key] = const_cast(wpt); tmpwpt->extra_data = gb_int2ptr(waypoint_num + 1); /* NOT NULL */ humminbird_write_waypoint(wpt); } else { void* p = tmpwpt->extra_data; - tmpwpt = (Waypoint*)wpt; + tmpwpt = const_cast(wpt); tmpwpt->extra_data = p; } diff --git a/lowranceusr4.cc b/lowranceusr4.cc index a2a0a2fdb..54cd5c13d 100644 --- a/lowranceusr4.cc +++ b/lowranceusr4.cc @@ -300,7 +300,7 @@ static void register_waypt(const Waypoint* ref) { int i; - Waypoint* wpt = (Waypoint*) ref; + Waypoint* wpt = const_cast(ref); for (i = 0; i < waypt_table_ct; i++) { Waypoint* cmp = waypt_table[i]; diff --git a/mmo.cc b/mmo.cc index 985656981..b4b103e20 100644 --- a/mmo.cc +++ b/mmo.cc @@ -250,7 +250,7 @@ mmo_register_object(const int objid, const void* ptr, const gpsdata_type type) mmo_data_t* data; data = (mmo_data_t*) xcalloc(1, sizeof(*data)); - data->data = (void*)ptr; + data->data = const_cast(ptr); data->visible = 1; data->locked = 0; data->type = type; @@ -956,7 +956,7 @@ mmo_read_object() static void mmo_finalize_rtept_cb(const Waypoint* wptref) { - Waypoint* wpt = (Waypoint*)wptref; + Waypoint* wpt = const_cast(wptref); if ((wpt->shortname[0] == 1) && (wpt->latitude == 0) && (wpt->longitude == 0)) { mmo_data_t* data; @@ -1340,7 +1340,7 @@ mmo_write_rte_head_cb(const route_head* rte) return; } - mmo_rte = (route_head*)rte; + mmo_rte = const_cast(rte); QUEUE_FOR_EACH(&rte->waypoint_list, elem, tmp) { Waypoint* wpt = (Waypoint*)elem; diff --git a/osm.cc b/osm.cc index 869916bac..6cb3a55a6 100644 --- a/osm.cc +++ b/osm.cc @@ -461,7 +461,7 @@ osm_strip_html(const char* str) { utf_string utf; utf.is_html = true; - utf.utfstring = (char*)str; + utf.utfstring = const_cast(str); return strip_html(&utf); // util.cc } @@ -775,7 +775,7 @@ static void osm_release_ids(const Waypoint* wpt) { if (wpt && wpt->extra_data) { - Waypoint* tmp = (Waypoint*)wpt; + Waypoint* tmp = const_cast(wpt); xfree(tmp->extra_data); tmp->extra_data = nullptr; } @@ -806,7 +806,7 @@ osm_waypt_disp(const Waypoint* wpt) id = (int*) xmalloc(sizeof(*id)); *id = --node_id; - ((Waypoint*)(wpt))->extra_data = id; + (const_cast(wpt))->extra_data = id; gbfprintf(fout, " latitude, wpt->longitude); if (wpt->creation_time.isValid()) { diff --git a/position.cc b/position.cc index 778a503a1..5b9688253 100644 --- a/position.cc +++ b/position.cc @@ -134,8 +134,8 @@ void PositionFilter::position_process_any_route(const route_head* rh, int type) int i = rh->rte_waypt_ct; if (i) { - cur_rte = (route_head*)rh; - position_runqueue((queue*)&rh->waypoint_list, i, type); + cur_rte = const_cast(rh); + position_runqueue(const_cast(&rh->waypoint_list), i, type); cur_rte = nullptr; } diff --git a/raymarine.cc b/raymarine.cc index 6de96185a..b31be2f0a 100644 --- a/raymarine.cc +++ b/raymarine.cc @@ -288,7 +288,7 @@ static void register_waypt(const Waypoint* ref, const char) { int i; - Waypoint* wpt = (Waypoint*) ref; + Waypoint* wpt = const_cast(ref); for (i = 0; i < waypt_table_ct; i++) { Waypoint* cmp = waypt_table[i]; @@ -317,13 +317,13 @@ register_waypt(const Waypoint* ref, const char) static void enum_waypt_cb(const Waypoint* wpt) { - register_waypt((Waypoint*) wpt, 0); + register_waypt(const_cast(wpt), 0); } static void enum_rtept_cb(const Waypoint* wpt) { - register_waypt((Waypoint*) wpt, 1); + register_waypt(const_cast(wpt), 1); } static int diff --git a/reverse_route.cc b/reverse_route.cc index b8202be47..182c04df3 100644 --- a/reverse_route.cc +++ b/reverse_route.cc @@ -33,7 +33,7 @@ void ReverseRouteFilter::reverse_route_wpt(const Waypoint* waypointp) { /* Cast away const-ness */ - Waypoint* wpp = (Waypoint*) waypointp; + Waypoint* wpp = const_cast(waypointp); int curr_new_trkseg; diff --git a/route.cc b/route.cc index 631c218d1..cc440fa84 100644 --- a/route.cc +++ b/route.cc @@ -263,7 +263,7 @@ void route_reverse(const route_head* rte_hd) { /* Cast away const-ness */ - route_head* rh = (route_head*) rte_hd; + route_head* rh = const_cast(rte_hd); queue* elem, *tmp; QUEUE_FOR_EACH(&rh->waypoint_list, elem, tmp) { ENQUEUE_HEAD(&rh->waypoint_list, dequeue(elem)); diff --git a/stmsdf.cc b/stmsdf.cc index 7dd66f326..fd76f2cb3 100644 --- a/stmsdf.cc +++ b/stmsdf.cc @@ -509,7 +509,7 @@ any_hdr_calc_cb(const route_head* trk) rte_desc = trk->rte_desc; } - trk_out = (route_head*)trk; + trk_out = const_cast(trk); } static void @@ -544,7 +544,7 @@ any_waypt_calc_cb(const Waypoint* wpt) this_time += (wpt->GetCreationTime().toTime_t() - trkpt_out->GetCreationTime().toTime_t()); } - trkpt_out = (Waypoint*)wpt; + trkpt_out = const_cast(wpt); } static void @@ -566,7 +566,7 @@ track_disp_hdr_cb(const route_head* trk) { track_index++; track_points = 0; - trk_out = (route_head*)trk; + trk_out = const_cast(trk); trkpt_out = nullptr; } @@ -630,7 +630,7 @@ track_disp_wpt_cb(const Waypoint* wpt) gbfprintf(fout, ",0\n"); } - trkpt_out = (Waypoint*)wpt; + trkpt_out = const_cast(wpt); } static void diff --git a/swapdata.cc b/swapdata.cc index 1204a5017..25dfa3938 100644 --- a/swapdata.cc +++ b/swapdata.cc @@ -30,7 +30,7 @@ void SwapDataFilter::swapdata_cb(const Waypoint* ref) { - Waypoint* wpt = (Waypoint*)ref; + Waypoint* wpt = const_cast(ref); double x; x = wpt->latitude; diff --git a/trackfilter.cc b/trackfilter.cc index f5258559d..22ddcd86a 100644 --- a/trackfilter.cc +++ b/trackfilter.cc @@ -60,7 +60,7 @@ int TrackFilter::trackfilter_parse_time_opt(const char* arg) { time_t t0, t1; int sign = 1; - char* cin = (char*)arg; + char* cin = const_cast(arg); char c; t0 = t1 = 0; @@ -178,7 +178,7 @@ void TrackFilter::trackfilter_fill_track_list_cb(const route_head* track) /* ca queue* elem, *tmp; if (track->rte_waypt_ct == 0) { - track_del_head((route_head*)track); + track_del_head(const_cast(track)); return; } @@ -186,15 +186,15 @@ void TrackFilter::trackfilter_fill_track_list_cb(const route_head* track) /* ca if (!QRegExp(opt_name, Qt::CaseInsensitive, QRegExp::WildcardUnix).exactMatch(track->rte_name)) { QUEUE_FOR_EACH((queue*)&track->waypoint_list, elem, tmp) { Waypoint* wpt = (Waypoint*)elem; - track_del_wpt((route_head*)track, wpt); + track_del_wpt(const_cast(track), wpt); delete wpt; } - track_del_head((route_head*)track); + track_del_head(const_cast(track)); return; } } - track_list[track_ct].track = (route_head*)track; + track_list[track_ct].track = const_cast(track); i = 0; prev = nullptr; @@ -234,7 +234,7 @@ void TrackFilter::trackfilter_minpoint_list_cb(const route_head* track) { int minimum_points = atoi(opt_minpoints); if (track->rte_waypt_ct < minimum_points) { - track_del_head((route_head*)track); + track_del_head(const_cast(track)); return; } } @@ -747,7 +747,7 @@ time_t TrackFilter::trackfilter_range_check(const char* timestr) i = 0; strncpy(fmt, "00000101000000", sizeof(fmt)); - cin = (char*)timestr; + cin = const_cast(timestr); while ((c = *cin++)) { if (fmt[i] == '\0') { @@ -1044,7 +1044,7 @@ void TrackFilter::trackfilter_segment_head(const route_head* rte) Waypoint* next_wpt = (Waypoint*) QUEUE_NEXT(&wpt->Q); if (trackfilter_points_are_same(prev_wpt, wpt) && trackfilter_points_are_same(wpt, next_wpt)) { - track_del_wpt((route_head*)rte, wpt); + track_del_wpt(const_cast(rte), wpt); continue; } } diff --git a/unicsv.cc b/unicsv.cc index 5713ea628..55b79acd0 100644 --- a/unicsv.cc +++ b/unicsv.cc @@ -462,7 +462,7 @@ unicsv_adjust_time(const time_t time, time_t* date) static char unicsv_compare_fields(const char* s, const field_t* f) { - char* name = (char*)f->name; + char* name = const_cast(f->name); const char* test = s; char result; diff --git a/util.cc b/util.cc index dfe4e6213..66a1dab07 100644 --- a/util.cc +++ b/util.cc @@ -124,7 +124,7 @@ XFREE(const void* mem, DEBUG_PARAMS) xfree(const void* mem) #endif { - free((void*) mem); + free(const_cast(mem)); #ifdef DEBUG_MEM debug_mem_output("free, %x, %s, %d\n", mem, file, line); @@ -167,7 +167,7 @@ xstrndup(const char* str, size_t sz) #endif { size_t newlen = 0; - char* cin = (char*)str; + char* cin = const_cast(str); char* newstr; while ((newlen < sz) && (*cin != '\0')) { @@ -484,8 +484,8 @@ str_match(const char* str, const char* match) { char* m, *s; - s = (char*)str; - m = (char*)match; + s = const_cast(str); + m = const_cast(match); while (*m || *s) { switch (*m) { @@ -1121,7 +1121,7 @@ gstrsub(const char* s, const char* search, const char* replace) { int ooffs = 0; char* o, *c; - char* src = (char*)s; + char* src = const_cast(s); int olen = strlen(src); int slen = strlen(search); int rlen = strlen(replace); @@ -1212,7 +1212,7 @@ convert_human_date_format(const char* human_datef) prev = '\0'; ylen = 0; - for (cin = (char*)human_datef; *cin; cin++) { + for (cin = const_cast(human_datef); *cin; cin++) { char okay = 1; if (toupper(*cin) != 'Y') { @@ -1278,7 +1278,7 @@ convert_human_time_format(const char* human_timef) cout = result; prev = '\0'; - for (cin = (char*)human_timef; *cin; cin++) { + for (cin = const_cast(human_timef); *cin; cin++) { int okay = 1; if (isalpha(*cin)) { diff --git a/vecs.cc b/vecs.cc index f92b43aca..5417f1af3 100644 --- a/vecs.cc +++ b/vecs.cc @@ -1179,7 +1179,7 @@ assign_option(const char* module, arglist_t* ap, const char* val) if (case_ignore_strcmp(val, ap->argstring) == 0) { c = ""; } else { - c = (char*)val; + c = const_cast(val); } switch (ap->argtype & ARGTYPE_TYPEMASK) { @@ -1290,7 +1290,7 @@ find_vec(const char* vecname, const char** opts) if (opt) { found = 1; assign_option(svecname, ap, opt); - xfree((char*)opt); + xfree(const_cast(opt)); continue; } } @@ -1347,7 +1347,7 @@ find_vec(const char* vecname, const char** opts) if (opt) { found = 1; assign_option(svecname, ap, opt); - xfree((char*)opt); + xfree(const_cast(opt)); continue; } } -- 2.30.2